from loguru import logger
from selenium import webdriver

from base.basePage import basePageHandler
from elements.first_page_elements import FirstPage


class firstPage(basePageHandler):
    def __init__(self, driver, message=""):
        self.driver = driver

    def open_doc(self):
        self.get("https://mubu.com/app")
        self.click_element(FirstPage.SKIP_ELEMENT)
        logger.info(f"点击首页弹框  {FirstPage.SKIP_ELEMENT}")
        return self

    def click_create_button(self):
        """点击新建按钮"""
        self.click_element(FirstPage.CREATE_BUTTON_ELEMENT)
        # logger.info(f"点击新建按钮  {FirstPage.CREATE_BUTTON_ELEMENT}")
        return self

    def click_create_dom(self):
        """点击新建文档"""

        self.click_element(FirstPage.CREATE_DOM_ELEMENT, step="")
        logger.info(f"点击新建按钮  {FirstPage.CREATE_DOM_ELEMENT}")
        return self

    def up_my_dom(self):
        """收起我的文档"""
        self.click_element(FirstPage.UP_MY_DOM_ELEMENT)
        logger.info(f"收起我的文档  {FirstPage.UP_MY_DOM_ELEMENT}")
        return self

    def click_study_alter(self):
        """点击使用教程弹框"""

        self.click_by_js(FirstPage.STUDY_ALTER_ELEMENT)
        logger.info(f"{self.click_study_alter.__doc__}  {FirstPage.STUDY_ALTER_ELEMENT}")
        return self

    def send_text_title(self, value):
        """输入文档title"""

        self.send_key(FirstPage.SEND_TITLE_ELEMENT, value)
        logger.info(f"收起我的文档  {FirstPage.SEND_TITLE_ELEMENT}")
        return self
